Use Runtime Entities in Business Rules
Overview
Runtime entities contain read-only information related to Bizagi’s process and case internal data. These entities are created by default in each project, and you may not create additional entities nor modify their attributes.
The information from Runtime entities is easily exposed for business rules and can only be used within Process activities.
Since Runtime entities require the context of a case to retrieve information, they are not available in global objects such as Entity rules or Library rules.
Key Points:
- Starting point for Xpath navigation:
<Case>
is used to reach attributes and collections available. - Read-only attributes: Cannot write values over Runtime entities' attributes.
- Collections: Return a Bizagi array list, which can be filtered and navigated to obtain the data required.
- Xpath functions supported: Functions like
<max()>
,<count()>
,<min()>
are supported. - Collections in Runtime entities: Can be used with the entity-list function:
Me.getXPath("entity-list('CaseInfo','')");
. - Unsupported functions: Functions like
Me.setXPath
,CHelper.setAttrib
, and setting values directly via Xpath are not supported for Runtime entities. - Function limitations: Functions that alter collections (e.g.,
attachCollectionItem
,deleteAllCollectionItem
,detachAllCollectionItem
,newCollectionItem
) are not supported for Runtime entities.
Building Runtime Entities Xpaths
Simple Xpaths
- Case number:
<Case.CaseNumber>
- Process display name:
<Case.ProcessDisplayName>
- Creator user's full name:
<Case.CreatorUser.fullName>
Since the CreatorUser is related to the WFUser table, all the WFUser attributes (e.g., email, delegate, language, boss) are accessible via Xpath.
Collection Xpaths
-
Name of all activities created in the process:
<Case.Activities.ActivityName>
- Returns information in the form of a Bizagi array list.
- Example:
[Request vacation leave, Approve request]
-
Full name of all performers of the case:
<Case.Activities.Performer.fullName>
- Returns information in the form of a Bizagi array list.
- Example:
[John Doe, Sarah Brown]
-
Types of allocations that the case has gone through:
<Case.Activities.PerformerHistory.AllocationType>
- Information is returned in the form of a Bizagi array list, with each activity registered multiple times.
- Example:
[Candidate, BestCandidate, Assignee, Candidate, BestCandidate, Assignee]
-
List of performers by allocation type:
<Case.Activities.PerformerHistory.IdAllocationPerformer.fullName>
- Information is returned in the form of a Bizagi array list, with repeated names due to the entity structure.
- Example:
[John Doe, John Doe, John Doe, Sarah Brown, Sarah Brown, Sarah Brown]
Example 1: Retrieving Case Status
For illustration purposes, the following example displays two ways in which the same information can be retrieved.
Both options return the same information: the status that a case has gone through.
Navigating through entity-list
var parameters = new FilterParameters();
parameters.AddParameter("@idcase", Me.Case.Id);
var BizagiArrayListObject = Me.getXPath(
"entity-list('BA_CaseStatusHistory','IdCase =@idcase')"
);
for (var i = 0; i < BizagiArrayListObject.size(); i++) {
var RowObject = BizagiArrayListObject.get(i);
var Value = RowObject.getXPath("CaseStatus");
}
Navigating using Xpath
var Cases = <Case.CaseStatusHistory.CaseStatus>;
for (var j = 0; j < Cases.size(); j++) {
var RowObject2 = Cases.get(j);
}
Example 2: Obtaining Current Task Name
var idworkitem = Me.Id;
var CurrentActivity = Me.getXPath("Case.Activities[IdActivity=" + idworkitem + "]");
CurrentActivity.getXPath("ActivityName");
Example 3: Obtaining the Identifier of the First User Allocated to the Current Task
var idworkitem = Me.Id;
var CurrentActivity = Me.getXPath("Case.Activities[IdActivity=" + idworkitem + "]");
var user = CurrentActivity.getXPath("Performer").get(0);
user.getXPath("idUser");